package jumpingnotes.dao.hibernate;

import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;

import jumpingnotes.dao.DeployDAO;
import jumpingnotes.dao.Sorter;
import jumpingnotes.model.Audio;
import jumpingnotes.model.Deploy;

public class DeployHibernateDAO extends GenericHibernateDAO<Deploy> implements DeployDAO
{
	public DeployHibernateDAO()
	{
		super(Deploy.class);
	}

	public List<Deploy> findByAudioUuid(final String audioUuid)
	{
		return (List<Deploy>) getHibernateTemplate().execute(new HibernateCallback()
		{
			public Object doInHibernate(Session session) throws HibernateException
			{
				Query query = session.createQuery("from Deploy d where d.audio.resourceUuid=:audioUuid")
					.setString("audioUuid", audioUuid);							
				return query.list();
			}
		}, true);
	}
}
